const AutoImport = require('unplugin-auto-import/webpack');
const Components = require('unplugin-vue-components/webpack');
const {
	ElementPlusResolver
} = require('unplugin-vue-components/resolvers');

module.exports = {
	publicPath: process.env.NODE_ENV === 'production' ? '' : './',
	// 输出文件目录
	outputDir: process.env.NODE_ENV === 'production' ? 'dist' : 'devdist',
	// eslint-loader 是否在保存的时候检查
	lintOnSave: true,
	chainWebpack: config => {},
	configureWebpack: {
		plugins: [
			// 自动导入
			AutoImport({
				resolvers: [ElementPlusResolver()]
			}),
			Components({
				resolvers: [ElementPlusResolver()]
			})
		]
	},
	// 生产环境是否生成 sourceMap 文件
	productionSourceMap: false,
	// css相关配置
	css: {
		// 是否使用css分离插件 ExtractTextPlugin
		extract: true,
		// 开启 CSS source maps?
		sourceMap: false,
		// css预设器配置项
		loaderOptions: {
			sass: {
				prependData: `@import "./src/styles/main.scss";`
			}
		}
	},
	// use thread-loader for babel & TS in production build
	// enabled by default if the machine has more than 1 cores
	parallel: require('os').cpus().length > 1,
	/**
	 *  PWA 插件相关配置,see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
	 */
	pwa: {},
	// webpack-dev-server 相关配置
	devServer: {},
	/**
	 * 第三方插件配置
	 */
	pluginOptions: {}
};
